#include<cstdio>
#include<cstring>

int a[100][100];

int main(){
	int n,x,y,tot=0;
	scanf("%d",&n);
	memset(a,0,sizeof(a));
	tot = a[x = n-1][y = n-1] = n*n;
	while(tot > 1){
		while(y-1>=0 && !a[x][y-1])	a[x][--y] = --tot;
		while(x-1>=0 && !a[x-1][y])	a[--x][y] = --tot;
		while(y+1<n && !a[x][y+1])	a[x][++y] = --tot;
		while(x+1<n && !a[x+1][y])	a[++x][y] = --tot;
	}
	for(x = 0;x<n;x++){
		for(y = 0;y<n;y++){
			printf("%d ",a[x][y]);	
		}
		printf("\n");
	}
	int he=0;
	for(int i=0;i<n;i++){
		he+=a[i][i];
		he+=a[i][n-1-i];
	}
	if(n%2 != 0)	he-=1;
	printf("%d",he);
	return 0;
}
